import request from "@/utils/request";

// 查询会议事项列表
export function listMeetingTask(query) {
  return request({
    url: "/officeMeeting/meetingTask/list",
    method: "get",
    params: query,
  });
}
// 查询未完成会议事项列表
export function listMeetingUNTask(query) {
  return request({
    url: "/officeMeeting/meetingTask/toDoMeetingItems",
    method: "get",
    params: query,
  });
}

// 查询会议事项所有列表
export function listAllMeetingTask(query) {
  return request({
    url: "/officeMeeting/meetingTask/listAll",
    method: "get",
    params: query,
  });
}

// 查询会议事项详细
export function getMeetingTask(id) {
  return request({
    url: "/officeMeeting/meetingTask/getInfo/" + id,
    method: "get",
  });
}

// 新增会议事项
export function addMeetingTask(data) {
  return request({
    url: "/officeMeeting/meetingTask/add",
    method: "post",
    data: data,
  });
}

// 批量新增会议事项：
export function addMeetingTaskList(meetingId, data) {
  return request({
    url: "/officeMeeting/meetingTask/addByList/" + meetingId,
    method: "post",
    data: data,
  });
}

// 修改会议事项
export function updateMeetingTask(data) {
  return request({
    url: "/officeMeeting/meetingTask/edit",
    method: "post",
    data: data,
  });
}

// 删除会议事项
export function delMeetingTask(id) {
  return request({
    url: "/officeMeeting/meetingTask/remove/" + id,
    method: "get",
  });
}

// 上传会议附件
export function addMeetingFileInfo(relatedRefId, files) {
  const formData = new FormData();
  (files || []).forEach((file) => {
    formData.append("files", file);
  });
  formData.append("relatedRefId", relatedRefId);
  return request({
    url: "/officeMeeting/attachment/addOfficeAttachment",
    method: "post",
    data: formData,
    headers: {
      "X-Requested-With": "XMLHttpRequest",
    },
  });
}
// 查询会议附件列表
export function getMeetingTaskFileList(query) {
  return request({
    url: "/officeMeeting/attachment/listAll",
    method: "get",
    params: query,
  });
}
// 删除会议附件
export function delMeetingFile(id) {
  return request({
    url: "/officeMeeting/attachment/remove/" + id,
    method: "get",
  });
}

// 会议统计列表
export function meetingTotals(data) {
  return request({
    // 接口格式: /statistics?dateQuery=2025-11-18
    url: "/officeMeeting/meetingRecord/statistics",
    method: "get",
    params: data,
  });
}
